#include "rclcpp/rclcpp.hpp"
#include "std_msgs/msg/string.hpp"

class PublisherNode : public rclcpp::Node
{
	//publish string message to topic "command" every 0.5 seconds
  private:
	rclcpp::Publisher<std_msgs::msg::String>::SharedPtr publisher;
	rclcpp::TimerBase::SharedPtr timer;
  public:
	PublisherNode(std::string name) : Node(name)
	{
		RCLCPP_INFO(this->get_logger(), "this is %s", name.c_str());
		publisher = this->create_publisher<std_msgs::msg::String>("command", 10);
		timer = this->create_wall_timer(std::chrono::milliseconds(500), std::bind(&PublisherNode::timer_callback, this));
		return;
	}
	void timer_callback()
	{
		std_msgs::msg::String message;
		message.data = "dummy command";
		RCLCPP_INFO(this->get_logger(), "timer up");
		publisher->publish(message);
	}
};

int main(int argc, char **argv)
{
	rclcpp::init(argc, argv);
	auto node = std::make_shared<PublisherNode>("command_publisher");
	rclcpp::spin(node);
	rclcpp::shutdown();
	return 0;
}


